<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Event</title>
</head>
<body>
    <div id="example">
        <button v-on:click="greet">Greet</button>
    </div>
    <div id="example2">
        <button v-on:click="say('Hi, nice to meet you here')" v-on:keyup.esc="say('You pressed esc')">Say Hi</button>
        <button v-on:click="say('Bye, see you next time!')">Say Bye</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
    <script>
        var example = new Vue({
            el: "#example",
            data: {
                name: 'Vue.js'
            },
            methods: {
                greet: function(event) {
                    alert("Hello " + this.name)
                    if (event) {
                        alert(event.target.tagName)
                    }
                }
            }
        })
        var example2 = new Vue({
            el: '#example2',
            methods: {
                say: function(message) {
                    alert(message)
                }
            }
        })
    </script>
</body>
</html>